home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / V101PT2 < prev    next >
Text File  |  1989-04-26  |  19KB  |  298 lines

  1. Portal-Rmail-To: garyt@cup.portal.com
  2. Received: by portal.com (3.2/Portal 8)
  3.     id AA13156; Wed, 26 Apr 89 01:38:23 PDT
  4. Received: from Sun.COM (arpa-dev) by sun.Sun.COM (4.0/SMI-4.0)
  5.     id AA18522; Tue, 25 Apr 89 23:07:59 PDT
  6. Received: from sun by Sun.COM (4.1/SMI-4.0)
  7.     id AB12617; Tue, 25 Apr 89 23:07:12 PDT
  8. Message-Id: <8904260607.AB12617@Sun.COM>
  9. Received: from LEHIIBM1.BITNET by IBM1.CC.Lehigh.Edu (IBM VM SMTP R1.2) with BSMTP id 5945; Wed, 26 Apr 89 02:02:46 EDT
  10. Received: by LEHIIBM1 (Mailer R2.03A) id 5720; Wed, 26 Apr 89 02:02:42 EDT
  11. Date:         Wed, 26 Apr 89 02:02:41 EDT
  12. From: Revised List Processor (1.5o) <LISTSERV@IBM1.CC.Lehigh.Edu>
  13. Subject:      File: "V101 2" being sent to you
  14. To: "Gary F. Tom" <sun!portal!cup.portal.com!garyt>
  15.  
  16. Subject: Virus 101 - Chapter 2
  17. From: woodside@ttidca.TTI.COM (George Woodside)
  18. Newsgroups: comp.sys.atari.st,comp.sys.apple,comp.sys.mac,comp.sys.ibm.pc
  19. Date: 6 Mar 89 14:00:21 GMT
  20. Reply-To: woodside@ttidcb.tti.com (George Woodside)
  21. Organization: Citicorp/TTI, Santa Monica
  22.  
  23. In response to a lot of the mail I've received:
  24.  
  25. 1) You haven't missed the "rest of the chapters". I'm posting them as I
  26.    get them written.
  27.  
  28. 2) You may not agree with me. I tried to set down the definitions and
  29.    terms as I would be using them, for the benefit of those who weren't
  30.    familiar with them. This whole area is rather vague, and most of us
  31.    in the trenches and making up the rules, as we learn the game.
  32.  
  33. When we left our virus at the end of Chapter 1, it had managed to get itself
  34. installed in our system by being present on the boot sector of a disk in the
  35. machine at cold start or reset.
  36.  
  37. Another way a virus may be installed is via a trojan horse program. Trojan
  38. horses come in many flavors. Some disguise themselves as programs which
  39. provide some useful function or service, while secretly doing something
  40. else. The something else may be installing a virus, sabotaging some part of
  41. a disk, setting up hooks to steal passwords on time sharing systems, or
  42. whatever else you can imagine. In the event of the virus installer, the
  43. trojan horse has a bit more flexibility than a typical boot sector virus,
  44. simply because it doesn't have to fit itself into a relatively small space.
  45. Since it is hiding in a larger program, it can be whatever size is necessary
  46. to accomplish the task.
  47.  
  48. A typical boot sector contains information about the layout of the disk it
  49. resides upon. This block of data requires 26 bytes. The first three bytes of
  50. the boot sector are left available for an assembly language "jump" command,
  51. to allow the execution of the code to skip over the boot sector's data
  52. block. And, the boot sector must add up to the proper magic number to have
  53. executable status. That will require another two bytes, since the checksum
  54. is a 16 bit value. So, 31 bytes are allocated. Since (at least in the 68000
  55. family) machine instructions are always 16 bits and must begin on an even
  56. address, 32 of the 512 bytes in the boot sector are not available to any
  57. executable program. So, there are 480 bytes available for the executable
  58. code. Machine instructions vary in length, depending upon what they do, and
  59. how much additional information is required. In the 68000, instruction
  60. lengths vary from one to five words, but a reasonable average instruction
  61. length for a program is just over two words. That translates the 480 bytes
  62. to 120 instructions.
  63.  
  64. The virus must contain the code to install itself, reserve the memory it
  65. occupies to keep subsequent programs from over-writing it, spread itself to
  66. other disks, and whatever it really intends to do once it decides it is time
  67. to act. That's quite a bit of code to fit into 120 instructions, unless it
  68. extends itself by loading some other part of the disk, or a file.
  69.  
  70. Files are pretty much out of the question. Most computer users would notice
  71. if some file they didn't recognize started popping up on a lot of their
  72. disks. There are attributes settable in a disk directory which can be used
  73. to tell the operating system that certain files are "Hidden" or "System"
  74. files. If the file had the proper status bits set, it could prevent itself
  75. from appearing in normal disk directory displays. There are, however, more
  76. flexible disk directory listing programs which will display the entries for
  77. these files, as well as normal files. There is also the problem of the space
  78. the hidden file occupies, as well as the directory entry. The space
  79. available on the disk will be less than it should be, since the hidden file
  80. is present. These symptoms would not escape detection for long.
  81.  
  82. A more effective method is the use of specific disk sectors. The standard
  83. disk layout covered in the preceeding chapter mentioned such things as File
  84. Allocation Tables, and disk directory space. In a standard format Atari
  85. disk, for example, each FAT is 5 sectors long, and the directory is 7
  86. sectors long. That is more than enough FAT space to accomodate the entire
  87. disk. A virus in need of more space than 480 bytes might write the remainder
  88. of itself in the last sector of the FAT (I have one that does this). It
  89. might also write itself in the last sector of the directory, taking
  90. advantage of a quirk in the operating system.
  91.  
  92. When a disk is formatted, all data sectors are normally filled with a
  93. pre-defined value, E5 (hexadecimal). The directory and FAT space is usually
  94. set to 00. When a directory entry is made active, the file name is written
  95. in the directory, along with some other required information. When a file is
  96. deleted, the first byte of the directory entry is set to E5. That makes the
  97. entry available again. This is a carry over from the early days of floppy
  98. disks, when where the directory would exist on a disk was not as well
  99. defined. The directory entries had to appear as empty on a freshly formatted
  100. disk, so E5 was used as a deleted entry mark. That way, no matter where the
  101. directory was, a freshly formatted disk would always appear as empty. Now,
  102. since disk formats are more flexible, the directory is located by
  103. parameters, and normally the entire directory space is zeroed at formatting
  104. time. Since an active entry will have some legitimate ASCII character in the
  105. beginning of the file name, and a deleted entry will have E5 in the first
  106. byte, it is generally assumed that encountering a directory entry with a
  107. value of 00 in the first byte indicates that the entry has never been used.
  108. Since directory entries are used (and deleted ones re-used) on a first-found
  109. basis, finding one with 00 means that not only has it not been used, but
  110. none of the ones following it will have been used either. Consequently, most
  111. software stops looking at the directory entries when a 00 entry pops up. If
  112. there are several more sectors available, there may be something hiding out
  113. there, beyond the last used entry. While this method of hiding is not
  114. foolproof, the typical virus is not concerned about being bulletproof in all
  115. cases. It just has to survive long enough to reproduce itself, and it has
  116. half the battle won. As long as it keeps spreading, sooner or later it will
  117. survive long enough to do the task it is designed to do, then it wins both
  118. halves of the battle.
  119.  
  120. There are other ways for the virus to get additional disk space. Typically,
  121. floppy disks are not used up a sector at a time, but rather in groups of
  122. sectors. Each group of sectors is referred to as a data "cluster". The
  123. number of sectors in a cluster is variable, and is one of the parameters
  124. stored in the boot sector. If the number of data sectors on the entire disk,
  125. minus the boot sector, FATs, and directory, is not an exact multiple of the
  126. number of sectors in a data cluster, the remaining sectors will never be
  127. used by the opearting system. A clever virus can find them and hide there.
  128. The inconvenience of this is that the unused sectors would normally be at
  129. the end of the last track of the disk, causing long (and noticeable) disk
  130. seeks to load or spread the virus.
  131.  
  132. There is a parameter in the boot sector designed to permit the disk to have
  133. sectors reserved for any purpose, and not access